function traceAdvancerGeneric3p0(traceNumber)
% traceAdvancerGeneric3p0
%
% See also traceAdvancer3p0, traceBrowserGeneric3p0, traceBrowser3p0
%
% Editing:
% gs april 2005
% --------------------------------------------------------

% get the data
handles = get(gcf, 'UserData');

% find the new trace number
if nargin == 0 % call was from slider/text
    style = get(gco, 'Style');
    switch style
        case 'edit'
            traceNumber = str2num(get(gco, 'String'));
        case 'slider'
            traceNumber = round(get(gco, 'Value'));
    end
elseif nargin == 1 % call was from pixTrace -- VESTIGIAL for this function
end

% exit now if the trace number is off-scale
if traceNumber < 1 | traceNumber > size(handles.data.map.mapActive.fArray, 2)
    return
end

% update the slider and text box
set(handles.data.fig.traceBrowserGeneric.htraceSlider, 'Value', traceNumber);
set(handles.data.fig.traceBrowserGeneric.htraceEdit, 'String', num2str(traceNumber));
handles.data.fig.traceBrowserGeneric.currentTrace = traceNumber;

% update the raw traces with the new values
contents = get(handles.genericBrowseType, 'String');
str = contents{get(handles.genericBrowseType, 'Value')};
switch str
    case 'baseline subtracted'
        set(handles.data.fig.traceBrowserGeneric.hcurrentTrace, 'YData', handles.data.map.mapActive.bsArray(:, traceNumber));
        
        axes(handles.data.fig.traceBrowserGeneric.hax1);
        set(handles.data.fig.traceBrowserGeneric.hstimLine, 'YData', ...
            [min(handles.data.map.mapActive.bsArray(:, traceNumber)) max(handles.data.map.mapActive.bsArray(:, traceNumber))]);
        axis tight;
        
        % update the lines in the raw trace plot
        set(handles.data.fig.traceBrowserGeneric.hstimLine, 'YData', get(handles.data.fig.traceBrowserGeneric.hax1, 'YLim'));
        
    case 'not baseline subtracted'
        set(handles.data.fig.traceBrowserGeneric.hcurrentTrace, 'YData', handles.data.map.mapActive.fArray(:, traceNumber));
        
        axes(handles.data.fig.traceBrowserGeneric.hax1);
        set(handles.data.fig.traceBrowserGeneric.hstimLine, 'YData', ...
            [min(handles.data.map.mapActive.fArray(:, traceNumber)) max(handles.data.map.mapActive.fArray(:, traceNumber))]);
        axis tight;
        
        % update the lines in the raw trace plot
        set(handles.data.fig.traceBrowserGeneric.hstimLine, 'YData', get(handles.data.fig.traceBrowserGeneric.hax1, 'YLim'));
        
    otherwise
end






% % % % --------------------------------------------------------
% % % % get the data
% % % handles = get(gcf, 'UserData');
% % % 
% % % % find the new trace number
% % % if nargin == 0 % call was from slider/text
% % %     style = get(gco, 'Style');
% % %     switch style
% % %         case 'edit'
% % %             traceNumber = str2num(get(gco, 'String'));
% % %         case 'slider'
% % %             traceNumber = round(get(gco, 'Value'));
% % %     end
% % % elseif nargin == 1 % call was from pixTrace
% % % end
% % % 
% % % % exit now if the trace number is off-scale
% % % if traceNumber < 1 | traceNumber > size(handles.data.map.mapActive.bsArray, 2)
% % %     return
% % % end
% % % 
% % % % update the slider and text box
% % % set(handles.data.fig.traceBrowser.htraceSlider, 'Value', traceNumber);
% % % set(handles.data.fig.traceBrowser.htraceEdit, 'String', num2str(traceNumber));
% % % handles.data.fig.traceBrowser.currentTrace = traceNumber;
% % % 
% % % % update the raw traces with the new values
% % % set(handles.data.fig.traceBrowser.hcurrentTrace, 'YData', handles.data.map.mapActive.bsArray(:, traceNumber));
% % % % if handles.data.analysis.numberOfMaps > 1
% % % %     hold on;
% % % %     for m = 2 : handles.data.analysis.numberOfMaps
% % % %         strA = ['handles.data.map.map' num2str(m)];
% % % %         strB = ['.bsArray(:, traceNumber)'];
% % % %         strC = [strA strB];
% % % %         
% % % %         strD = ['handles.data.fig.traceBrowser.hcurrentTrace' num2str(m)];
% % % % 
% % % %         eval(['set(' strD ', ''YData'', ' strC ');']);
% % % %             
% % % % %         eval(['data.handles.hcurrentTrace' num2str(m) ...
% % % % %                 ' = plot(xdata/handles.data.acq.sampleRate, ydataP1(:, ' num2str(m) '));']);
% % % % %         set(gco, 'Color', handles.data.analysis.colorOrder(m));
% % % %         % data.handles.hcurrentTraceP2 = plot(xdata/data.sampleRate, ydataP2, 'g-');
% % % %     end
% % % % end
% % % 
% % % % set(data.handles.hcurrentTraceP2, 'YData', data.P2.bsArrayP2(:, traceNumber));
% % % axes(handles.data.fig.traceBrowser.hax1);
% % % set(handles.data.fig.traceBrowser.hstimLine, 'YData', ...
% % %     [min(handles.data.map.mapActive.bsArray(:, traceNumber)) max(handles.data.map.mapActive.bsArray(:, traceNumber))]);
% % % axis tight;
% % % 
% % % % update the lines in the raw trace plot
% % % set(handles.data.fig.traceBrowser.hstimLine, 'YData', get(handles.data.fig.traceBrowser.hax1, 'YLim'));
% % % 
% % % % update pixel-indicating marker in maps
% % % [row col] = find(handles.data.map.mapActive.mapPattern == handles.data.fig.traceBrowser.currentTrace);
% % % y = (row - 1) * handles.data.map.mapActive.mapSpacing - handles.data.map.mapActive.magFacY;
% % % x = (col - 1) * handles.data.map.mapActive.mapSpacing - handles.data.map.mapActive.magFacX;
% % % set(handles.data.fig.traceBrowser.haxMap1_currentTrace, 'XData', x, 'YData', y);
% % % % set(handles.data.fig.traceBrowser.haxMap2_currentTrace, 'XData', x, 'YData', y);
% % % set(handles.data.fig.traceBrowser.haxSliceImg_currentTrace, 'XData', x, 'YData', y);
% % % 
% % % % % update the xcorr data
% % % % set(data.handles.hxcorr1, 'YData', data.xcorr.XC(:, traceNumber)');
% % % % 
% % % % % lines in the xcorr plot
% % % % set(data.handles.hzeroLine, 'YData', ...
% % % %     [min(data.xcorr.XC(:, traceNumber)) max(data.xcorr.XC(:, traceNumber))]);
% % % % set(data.handles.hmaxXCorr, 'YData', ...
% % % %     [min(data.xcorr.XC(:, traceNumber)) max(data.xcorr.XC(:, traceNumber))], ...
% % % %     'XData', [data.xcorr.maxXCorrLags(traceNumber) data.xcorr.maxXCorrLags(traceNumber)]);
% % % % 
% % % % axes(data.handles.hax2);
% % % % axis tight;
% % % % 
% % % % % update the lines in the xcorr plot
% % % % set(data.handles.hzeroLine, 'YData', get(data.handles.hax2, 'YLim'));
% % % % set(data.handles.hmaxXCorr, 'YData', get(data.handles.hax2, 'YLim'));
% % % 
